#include "stdafx.h"
#include "FreeTypeDemoView.h"

CFreeTypeDemoView::CFreeTypeDemoView()
{
	m_pMemDC = NULL;
}

CFreeTypeDemoView::~CFreeTypeDemoView()
{

}

LRESULT CFreeTypeDemoView::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    CPaintDC dc(m_hWnd);

    RECT rcClient;
	
    if (m_pMemDC)
    {
        GetClientRect(&rcClient);
        dc.BitBlt(0,  // x and
                  0,  // y - upper-left corner of place, where we'd like to copy
                  rcClient.right - rcClient.left, // width of the region
                  rcClient.bottom - rcClient.top, // height
                  m_pMemDC->m_hDC, // source
                  0,   // x and
                  0,   // y of upper left corner  of part of the source, from where we'd like to copy
                  SRCCOPY); // Defined DWORD to juct copy pixels. Watch more on msdn;
    } 
	
    return 0;
}

HDC CFreeTypeDemoView::GetMemDC()
{
	RECT rcClient;
	HDC  hDC;

	if (!m_pMemDC)
	{
		hDC = GetDC();
		GetClientRect(&rcClient);

		m_pMemDC = new CMemoryDC(hDC, rcClient);

		ReleaseDC(hDC);
	}

    return m_pMemDC->m_hDC;
}